/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.ncsu.csc.sensors;

import com.sun.spot.sensorboard.peripheral.LightSensor;
import com.sun.spot.sensorboard.EDemoBoard;

import java.io.IOException;
/**
 *
 * @author Richard Pospesel
 */
public class SPOTLightSensor implements Sensor
{
	LightSensor ls = (LightSensor)EDemoBoard.getInstance().getLightSensor();

	public SPOTLightSensor()
	{

	}

	public char getValue()
	{
		try
		{
			// sensor ranges from 0 to 740 according to sensor demo
			return (char)(ls.getAverageValue(5)/740.0 * 0xFFFF);
		}
		catch(IOException ioe)
		{
			
		}
		return 0;
	}
}
